import { ref, computed } from "vue";

/** 登录状态 */
export enum LoginStateEnum {
  /** 登录 */
  LOGIN,
  /** 注册 */
  REGISTER,
  /** 修改密码 */
  RESET_PASSWORD,
}

/** 当前页面状态 */
const currentState = ref(LoginStateEnum.LOGIN);

/** 登录页状态 */
export const useLoginState = () => {
  /** 修改登录页状态 */
  const setLoginState = (state: LoginStateEnum) => {
    currentState.value = state;
  };

  /** 获取登录页状态 */
  const getLoginState = computed(() => currentState.value);

  /** 返回登录状态 */
  const backLogin = () => {
    currentState.value = LoginStateEnum.LOGIN;
  };

  return {
    setLoginState,
    getLoginState,
    backLogin,
  };
};
